var t = getApp();

Page({
    data: {
        showSpec: !1,
        screenWidth: wx.getSystemInfoSync().windowWidth,
        specifes: [ {
            name: "600 x 600",
            value: "600 x 600"
        }, {
            name: "800 x 800",
            value: "800 x 800",
            checked: "true"
        }, {
            name: "900 x 600",
            value: "900 x 600"
        }, {
            name: "1200 x 600",
            value: "1200 x 600"
        }, {
            name: "1200 x 800",
            value: "1200 x 800"
        }, {
            name: "1200 x 2400",
            value: "1200 x 2400"
        }, {
            name: "1800 x 900",
            value: "1800 x 900"
        } ],
        attrs: {},
        imgUrl: "",
        server: t.server,
        serverUrl: t.serverUrl,
        horizon: [],
        vertical: [],
        method: "水平不对称",
        method1: "垂直不对称",
        w: null,
        h: null,
        specificationw: 800,
        specificationh: 800,
        remainderh: null,
        remainderw: null,
        materialText: "瓷砖",
        buttonType: "",
        buttonType1: "",
        disabled: !0,
        disabled1: !0,
        numMore: null,
        numMore1: null,
        width: null,
        height: null,
        height1: null
    },
    onLoad: function(t) {
        console.log("screenWidth", this.screenWidth), console.log(wx.getSystemInfoSync().windowWidth);
        var a = JSON.parse(t.attr);
        this.setData({
            attrs: a
        }), this.setData({
            width: parseInt(a.width)
        }), this.setData({
            height: parseInt(a.height)
        }), this.data.width > 680 ? (this.setData({
            height: 680 * this.data.height / this.data.width
        }), this.setData({
            width: parseInt(680)
        })) : (this.setData({
            height: parseInt(a.height)
        }), this.setData({
            width: parseInt(a.width)
        })), console.log("options11", this.data.attrs);
    },
    split: function() {
        if (this.setData({
            area: this.data.w * this.data.h / 1e6
        }), this.data.disabled && this.data.disabled1) {
            if ("水平不对称" == this.data.method) {
                for (var t = parseInt(this.data.w / this.data.specificationw), a = this.data.w % this.data.specificationw, i = [], s = 0; s < t; s++) i.push((this.data.specificationw / 10 + s * this.data.specificationw / 10) * (10 * this.data.width / this.data.w)), 
                a && s == t - 1 && i.push((this.data.specificationw / 10 + s * this.data.specificationw / 10) * (10 * this.data.width / this.data.w) + a / 10 * (10 * this.data.width / this.data.w));
                this.setData({
                    remainderw: a
                }), this.setData({
                    vertical: i
                });
            } else {
                var e = parseInt(this.data.w / this.data.specificationw), h = this.data.w % this.data.specificationw, n = [];
                if (h > 0) {
                    for (var d = (h + this.data.specificationw) / 2, c = 0; c < e - 1; c++) 0 == c && n.push((d / 10 + c * d / 10) * (10 * this.data.width / this.data.w)), 
                    n.push((this.data.specificationw / 10 + c * this.data.specificationw / 10 + d / 10) * (10 * this.data.width / this.data.w)), 
                    c == e - 2 && n.push((this.data.specificationw / 10 + c * this.data.specificationw / 10 + d / 10 + d / 10) * (10 * this.data.width / this.data.w));
                    this.setData({
                        remainderw: d
                    });
                } else {
                    for (var o = 0; o < e; o++) n.push((this.data.specificationw / 10 + o * this.data.specificationw / 10) * (10 * this.data.width / this.data.w)), 
                    h && o == e - 1 && n.push((this.data.specificationw / 10 + o * this.data.specificationw / 10) * (10 * this.data.width / this.data.w) + h / 10 * (10 * this.data.width / this.data.w));
                    this.setData({
                        remainderw: this.data.specificationw
                    });
                }
                this.setData({
                    vertical: n
                });
            }
            if ("垂直不对称" == this.data.method1) {
                for (var p = parseInt(this.data.h / this.data.specificationh), l = this.data.h % this.data.specificationh, r = [], u = 0; u < p; u++) r.push((this.data.specificationh / 10 + u * this.data.specificationh / 10) * (10 * this.data.height / this.data.h)), 
                l && u == p - 1 && r.push((this.data.specificationh / 10 + u * this.data.specificationh / 10) * (10 * this.data.height / this.data.h) + l / 10 * (10 * this.data.height / this.data.h));
                console.log(r), this.setData({
                    remainderh: l
                }), this.setData({
                    horizon: r
                });
            } else {
                var f = parseInt(this.data.h / this.data.specificationh), w = this.data.h % this.data.specificationh, D = [];
                if (w > 0) {
                    for (var v = (w + this.data.specificationh) / 2, m = 0; m < f - 1; m++) 0 == m && D.push((v / 10 + m * v / 10) * (10 * this.data.height / this.data.h)), 
                    D.push((this.data.specificationh / 10 + m * this.data.specificationh / 10 + v / 10) * (10 * this.data.height / this.data.h)), 
                    m == f - 2 && D.push((this.data.specificationh / 10 + m * this.data.specificationh / 10 + v / 10 + v / 10) * (10 * this.data.height / this.data.h));
                    this.setData({
                        remainderh: v
                    });
                } else {
                    for (var x = 0; x < f; x++) D.push((this.data.specificationh / 10 + x * this.data.specificationh / 10) * (10 * this.data.height / this.data.h)), 
                    w && x == f - 1 && D.push((this.data.specificationh / 10 + x * this.data.specificationh / 10) * (10 * this.data.height / this.data.h) + w / 10 * (10 * this.data.height / this.data.h));
                    this.setData({
                        remainderh: this.data.specificationh
                    });
                }
                this.setData({
                    horizon: D
                });
            }
        } else {
            var g = parseInt(this.data.w / this.data.numMore1), I = [];
            this.setData({
                specificationw: g
            });
            for (var b = 0; b < this.data.numMore1; b++) I.push((g / 10 + b * g / 10) * (10 * this.data.width / this.data.w));
            this.setData({
                vertical: I
            }), this.data.method, this.data.method1;
            var y = parseInt(this.data.h / this.data.numMore), T = [];
            this.setData({
                specificationh: y
            });
            for (var M = 0; M < this.data.numMore; M++) T.push((y / 10 + M * y / 10) * (10 * this.data.height / this.data.h));
            this.setData({
                horizon: T
            });
        }
    },
    splitMethod: function() {
        "水平不对称" == this.data.method ? this.setData({
            method: "水平对称"
        }) : this.setData({
            method: "水平不对称"
        }), this.split();
    },
    splitMethod1: function() {
        "垂直不对称" == this.data.method1 ? this.setData({
            method1: "垂直对称"
        }) : this.setData({
            method1: "垂直不对称"
        }), this.split();
    },
    material: function() {
        if (this.setData({
            horizon: []
        }), this.setData({
            vertical: []
        }), "瓷砖" == this.data.materialText) {
            var t = [ {
                name: "2400 x 1600",
                value: "2400 x 1600"
            }, {
                name: "3200 x 1600",
                value: "3200 x 1600",
                checked: "true"
            }, {
                name: "2700 x 1800",
                value: "2700 x 1800"
            } ];
            this.setData({
                materialText: "石材大板"
            }), this.setData({
                specificationw: 2400
            }), this.setData({
                specificationh: 1600
            }), this.setData({
                specifes: t
            });
        } else {
            var a = [ {
                name: "600 x 600",
                value: "600 x 600"
            }, {
                name: "800 x 800",
                value: "800 x 800",
                checked: "true"
            }, {
                name: "900 x 600",
                value: "900 x 600"
            }, {
                name: "1200 x 600",
                value: "1200 x 600"
            }, {
                name: "1200 x 800",
                value: "1200 x 800"
            }, {
                name: "1200 x 2400",
                value: "1200 x 2400"
            }, {
                name: "1800 x 900",
                value: "1800 x 900"
            } ];
            this.setData({
                materialText: "瓷砖"
            }), this.setData({
                specificationw: 800
            }), this.setData({
                specificationh: 800
            }), this.setData({
                specifes: a
            });
        }
    },
    bindSpec: function() {
        this.setData({
            showSpec: !0
        });
    },
    radioChange: function(t) {
        this.setData({
            horizon: []
        }), this.setData({
            vertical: []
        }), "瓷砖" == this.data.materialText ? "600 x 600" == t.detail.value ? (this.setData({
            specificationw: 600
        }), this.setData({
            specificationh: 600
        })) : "800 x 800" == t.detail.value ? (this.setData({
            specificationw: 800
        }), this.setData({
            specificationh: 800
        })) : "900 x 600" == t.detail.value ? (this.setData({
            specificationw: 900
        }), this.setData({
            specificationh: 600
        })) : "1200 x 600" == t.detail.value ? (this.setData({
            specificationw: 1200
        }), this.setData({
            specificationh: 600
        })) : "1200 x 800" == t.detail.value ? (this.setData({
            specificationw: 1200
        }), this.setData({
            specificationh: 800
        })) : "1200 x 2400" == t.detail.value ? (this.setData({
            specificationw: 1200
        }), this.setData({
            specificationh: 2400
        })) : "1800 x 900" == t.detail.value && (this.setData({
            specificationw: 1800
        }), this.setData({
            specificationh: 900
        })) : "2400 x 1600" == t.detail.value ? (this.setData({
            specificationw: 2400
        }), this.setData({
            specificationh: 1600
        })) : "3200 x 1600" == t.detail.value ? (this.setData({
            specificationw: 3200
        }), this.setData({
            specificationh: 1600
        })) : "2700 x 1800" == t.detail.value && (this.setData({
            specificationw: 2700
        }), this.setData({
            specificationh: 1800
        }));
    },
    sure: function() {
        this.setData({
            showSpec: !1
        });
    },
    buttonBg: function() {
        "" == this.data.buttonType ? this.setData({
            buttonType: "warn",
            disabled: !1
        }) : this.setData({
            buttonType: "",
            disabled: !0
        });
    },
    buttonBg1: function() {
        "" == this.data.buttonType1 ? this.setData({
            buttonType1: "warn",
            disabled1: !1
        }) : this.setData({
            buttonType1: "",
            disabled1: !0
        });
    },
    saveImg: function() {
        wx.canvasGetImageData({
            canvasId: "myCanvas",
            x: 0,
            y: 0,
            width: 100,
            height: 100,
            success: function(t) {
                console.log(t), console.log(t.height), console.log(t.data instanceof Uint8ClampedArray), 
                console.log(t.data.length);
            }
        });
    },
    onShow: function() {},
    widthInput: function(t) {
        this.setData({
            w: t.detail.value
        });
    },
    heightInput: function(t) {
        this.setData({
            h: t.detail.value
        });
    },
    numInput: function(t) {
        this.setData({
            numMore: t.detail.value
        });
    },
    numInput1: function(t) {
        this.setData({
            numMore1: t.detail.value
        });
    },
    onShareAppMessage: function() {}
});